<template>
  <div>
    <!-- 渲染的角色 列表-->
    <el-checkbox-group v-model="roleIds">
      <el-checkbox
        v-for="obj in allRoleList"
        :key="obj.id"
        :label="obj.id"
      >{{ obj.name }}</el-checkbox>

    </el-checkbox-group>

    <el-row class="footer" type="flex" justify="center">
      <el-col :span="6">
        <el-button type="primary" size="small" @click="enterFn">确定</el-button>
        <el-button size="small" @click="cancleDialog">取消</el-button>
      </el-col>
    </el-row>

  </div>
</template>
<script>
export default {
  name: 'AssignRole',
  props: {
    // 所有角色列表
    allRoleList: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {
      // 收集用户选择角色Id
      // 复选框v-model变量类名是数组 收集值
      //              变量类型非数组 收集选中状态
      roleIds: []
    }
  },
  methods: {
    // 确认按钮
    enterFn() {
      this.$emit('saveRoleIdsEv', this.roleIds)
    },
    // 取消弹框
    cancleDialog() {
      this.$emit('input', false)
    }
  }
}
</script>

<style lang="scss" scoped>
.footer {
  margin-top: 30px;
}
</style>
